home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / CIncludes / Windows.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-11  |  12.5 KB  |  386 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Windows.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. */
  16.  
  17. #ifndef __WINDOWS__
  18. #define __WINDOWS__
  19.  
  20.  
  21. #ifndef __MEMORY__
  22. #include <Memory.h>
  23. #endif
  24. /*    #include <Types.h>                                            */
  25. /*        #include <ConditionalMacros.h>                            */
  26. /*    #include <MixedMode.h>                                        */
  27.  
  28. #ifndef __QUICKDRAW__
  29. #include <Quickdraw.h>
  30. #endif
  31. /*    #include <QuickdrawText.h>                                    */
  32.  
  33. #ifndef __EVENTS__
  34. #include <Events.h>
  35. #endif
  36. /*    #include <OSUtils.h>                                        */
  37.  
  38. #ifndef __CONTROLS__
  39. #include <Controls.h>
  40. #endif
  41. /*    #include <Menus.h>                                            */
  42.  
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46.  
  47. #if GENERATINGPOWERPC
  48. #pragma options align=mac68k
  49. #endif
  50.  
  51. #ifdef __CFM68K__
  52. #pragma lib_export on
  53. #endif
  54.  
  55.  
  56. enum {
  57.     documentProc                = 0,
  58.     dBoxProc                    = 1,
  59.     plainDBox                    = 2,
  60.     altDBoxProc                    = 3,
  61.     noGrowDocProc                = 4,
  62.     movableDBoxProc                = 5,
  63.     zoomDocProc                    = 8,
  64.     zoomNoGrow                    = 12,
  65.     rDocProc                    = 16,
  66. /* floating window defproc ids */
  67.     floatProc                    = 1985,
  68.     floatGrowProc                = 1987,
  69.     floatZoomProc                = 1989,
  70.     floatZoomGrowProc            = 1991,
  71.     floatSideProc                = 1993,
  72.     floatSideGrowProc            = 1995,
  73.     floatSideZoomProc            = 1997,
  74.     floatSideZoomGrowProc        = 1999,
  75. /* window kinds */
  76.     dialogKind                    = 2,
  77.     userKind                    = 8,
  78. /*FindWindow Result Codes*/
  79.     inDesk                        = 0,
  80.     inMenuBar                    = 1,
  81.     inSysWindow                    = 2,
  82.     inContent                    = 3,
  83.     inDrag                        = 4,
  84.     inGrow                        = 5,
  85.     inGoAway                    = 6,
  86.     inZoomIn                    = 7,
  87.     inZoomOut                    = 8
  88. };
  89.  
  90. enum {
  91. /*window messages*/
  92.     wDraw                        = 0,
  93.     wHit                        = 1,
  94.     wCalcRgns                    = 2,
  95.     wNew                        = 3,
  96.     wDispose                    = 4,
  97.     wGrow                        = 5,
  98.     wDrawGIcon                    = 6,
  99.     deskPatID                    = 16,
  100. /*Window Part Identifiers which correlate color table entries with window elements*/
  101.     wContentColor                = 0,
  102.     wFrameColor                    = 1,
  103.     wTextColor                    = 2,
  104.     wHiliteColor                = 3,
  105.     wTitleBarColor                = 4
  106. };
  107.  
  108. enum {
  109.     wNoHit                        = 0,
  110.     wInContent                    = 1,
  111.     wInDrag                        = 2,
  112.     wInGrow                        = 3,
  113.     wInGoAway                    = 4,
  114.     wInZoomIn                    = 5,
  115.     wInZoomOut                    = 6
  116. };
  117.  
  118. typedef pascal long (*WindowDefProcPtr)(short varCode, WindowRef theWindow, short message, long param);
  119. /*
  120.         DeskHookProcPtr uses register based parameters on the 68k and cannot
  121.         be written in or called from a high-level language without the help of
  122.         mixed mode or assembly glue.
  123.  
  124.         In:
  125.          => mouseClick      D0.B
  126.          => *theEvent       A0.L
  127. */
  128.  
  129. #if GENERATINGCFM
  130. typedef UniversalProcPtr WindowDefUPP;
  131. typedef UniversalProcPtr DeskHookUPP;
  132. #else
  133. typedef WindowDefProcPtr WindowDefUPP;
  134. typedef Register68kProcPtr DeskHookUPP;
  135. #endif
  136.  
  137. enum {
  138.     uppWindowDefProcInfo = kPascalStackBased
  139.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  140.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  141.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(WindowRef)))
  142.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short)))
  143.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long))),
  144.     uppDeskHookProcInfo = kRegisterBased
  145.          | REGISTER_ROUTINE_PARAMETER(1, kRegisterD0, SIZE_CODE(sizeof(Boolean)))
  146.          | REGISTER_ROUTINE_PARAMETER(2, kRegisterA0, SIZE_CODE(sizeof(EventRecord*)))
  147. };
  148.  
  149. #if GENERATINGCFM
  150. #define NewWindowDefProc(userRoutine)        \
  151.         (WindowDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppWindowDefProcInfo, GetCurrentArchitecture())
  152. #define NewDeskHookProc(userRoutine)        \
  153.         (DeskHookUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppDeskHookProcInfo, GetCurrentArchitecture())
  154. #else
  155. #define NewWindowDefProc(userRoutine)        \
  156.         ((WindowDefUPP) (userRoutine))
  157. #define NewDeskHookProc(userRoutine)        \
  158.         ((DeskHookUPP) (userRoutine))
  159. #endif
  160.  
  161. #if GENERATINGCFM
  162. #define CallWindowDefProc(userRoutine, varCode, theWindow, message, param)        \
  163.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppWindowDefProcInfo, (varCode), (theWindow), (message), (param))
  164. #define CallDeskHookProc(userRoutine, mouseClick, theEvent)        \
  165.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppDeskHookProcInfo, (mouseClick), (theEvent))
  166. #else
  167. #define CallWindowDefProc(userRoutine, varCode, theWindow, message, param)        \
  168.         (*(userRoutine))((varCode), (theWindow), (message), (param))
  169. /* (*DeskHookProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  170. #endif
  171.  
  172. extern pascal RgnHandle GetGrayRgn( void )
  173.     TWOWORDINLINE( 0x2EB8, 0x09EE ); /* MOVE.L $09EE,(SP) */
  174. struct WinCTab {
  175.     long                            wCSeed;                        /*reserved*/
  176.     short                            wCReserved;                    /*reserved*/
  177.     short                            ctSize;                        /*usually 4 for windows*/
  178.     ColorSpec                        ctTable[5];
  179. };
  180. typedef struct WinCTab WinCTab;
  181.  
  182. typedef WinCTab *WCTabPtr, **WCTabHandle;
  183.  
  184. extern pascal void InitWindows(void)
  185.  ONEWORDINLINE(0xA912);
  186. extern pascal void GetWMgrPort(GrafPtr *wPort)
  187.  ONEWORDINLINE(0xA910);
  188. extern pascal WindowRef NewWindow(void *wStorage, const Rect *boundsRect, ConstStr255Param title, Boolean visible, short theProc, WindowRef behind, Boolean goAwayFlag, long refCon)
  189.  ONEWORDINLINE(0xA913);
  190. extern pascal WindowRef GetNewWindow(short windowID, void *wStorage, WindowRef behind)
  191.  ONEWORDINLINE(0xA9BD);
  192. extern pascal void CloseWindow(WindowRef theWindow)
  193.  ONEWORDINLINE(0xA92D);
  194. extern pascal void DisposeWindow(WindowRef theWindow)
  195.  ONEWORDINLINE(0xA914);
  196. extern pascal void GetWTitle(WindowRef theWindow, Str255 title)
  197.  ONEWORDINLINE(0xA919);
  198. extern pascal void SelectWindow(WindowRef theWindow)
  199.  ONEWORDINLINE(0xA91F);
  200. extern pascal void HideWindow(WindowRef theWindow)
  201.  ONEWORDINLINE(0xA916);
  202. extern pascal void ShowWindow(WindowRef theWindow)
  203.  ONEWORDINLINE(0xA915);
  204. extern pascal void ShowHide(WindowRef theWindow, Boolean showFlag)
  205.  ONEWORDINLINE(0xA908);
  206. extern pascal void HiliteWindow(WindowRef theWindow, Boolean fHilite)
  207.  ONEWORDINLINE(0xA91C);
  208. extern pascal void BringToFront(WindowRef theWindow)
  209.  ONEWORDINLINE(0xA920);
  210. extern pascal void SendBehind(WindowRef theWindow, WindowRef behindWindow)
  211.  ONEWORDINLINE(0xA921);
  212. extern pascal WindowRef FrontWindow(void)
  213.  ONEWORDINLINE(0xA924);
  214. extern pascal void DrawGrowIcon(WindowRef theWindow)
  215.  ONEWORDINLINE(0xA904);
  216. extern pascal void MoveWindow(WindowRef theWindow, short hGlobal, short vGlobal, Boolean front)
  217.  ONEWORDINLINE(0xA91B);
  218. extern pascal void SizeWindow(WindowRef theWindow, short w, short h, Boolean fUpdate)
  219.  ONEWORDINLINE(0xA91D);
  220. extern pascal void ZoomWindow(WindowRef theWindow, short partCode, Boolean front)
  221.  ONEWORDINLINE(0xA83A);
  222. extern pascal void InvalRect(const Rect *badRect)
  223.  ONEWORDINLINE(0xA928);
  224. extern pascal void InvalRgn(RgnHandle badRgn)
  225.  ONEWORDINLINE(0xA927);
  226. extern pascal void ValidRect(const Rect *goodRect)
  227.  ONEWORDINLINE(0xA92A);
  228. extern pascal void ValidRgn(RgnHandle goodRgn)
  229.  ONEWORDINLINE(0xA929);
  230. extern pascal void BeginUpdate(WindowRef theWindow)
  231.  ONEWORDINLINE(0xA922);
  232. extern pascal void EndUpdate(WindowRef theWindow)
  233.  ONEWORDINLINE(0xA923);
  234. extern pascal void SetWRefCon(WindowRef theWindow, long data)
  235.  ONEWORDINLINE(0xA918);
  236. extern pascal long GetWRefCon(WindowRef theWindow)
  237.  ONEWORDINLINE(0xA917);
  238. extern pascal void SetWindowPic(WindowRef theWindow, PicHandle pic)
  239.  ONEWORDINLINE(0xA92E);
  240. extern pascal PicHandle GetWindowPic(WindowRef theWindow)
  241.  ONEWORDINLINE(0xA92F);
  242. extern pascal Boolean CheckUpdate(EventRecord *theEvent)
  243.  ONEWORDINLINE(0xA911);
  244. extern pascal void ClipAbove(WindowRef window)
  245.  ONEWORDINLINE(0xA90B);
  246. extern pascal void SaveOld(WindowRef window)
  247.  ONEWORDINLINE(0xA90E);
  248. extern pascal void DrawNew(WindowRef window, Boolean update)
  249.  ONEWORDINLINE(0xA90F);
  250. extern pascal void PaintOne(WindowRef window, RgnHandle clobberedRgn)
  251.  ONEWORDINLINE(0xA90C);
  252. extern pascal void PaintBehind(WindowRef startWindow, RgnHandle clobberedRgn)
  253.  ONEWORDINLINE(0xA90D);
  254. extern pascal void CalcVis(WindowRef window)
  255.  ONEWORDINLINE(0xA909);
  256. extern pascal void CalcVisBehind(WindowRef startWindow, RgnHandle clobberedRgn)
  257.  ONEWORDINLINE(0xA90A);
  258. extern pascal long GrowWindow(WindowRef theWindow, Point startPt, const Rect *bBox)
  259.  ONEWORDINLINE(0xA92B);
  260. extern pascal short FindWindow(Point thePoint, WindowRef *theWindow)
  261.  ONEWORDINLINE(0xA92C);
  262. extern pascal long PinRect(const Rect *theRect, Point thePt)
  263.  ONEWORDINLINE(0xA94E);
  264. extern pascal long DragGrayRgn(RgnHandle theRgn, Point startPt, const Rect *limitRect, const Rect *slopRect, short axis, DragGrayRgnUPP actionProc)
  265.  ONEWORDINLINE(0xA905);
  266. extern pascal long DragTheRgn(RgnHandle theRgn, Point startPt, const Rect *limitRect, const Rect *slopRect, short axis, DragGrayRgnUPP actionProc)
  267.  ONEWORDINLINE(0xA926);
  268. extern pascal Boolean TrackBox(WindowRef theWindow, Point thePt, short partCode)
  269.  ONEWORDINLINE(0xA83B);
  270. extern pascal void GetCWMgrPort(CGrafPtr *wMgrCPort)
  271.  ONEWORDINLINE(0xAA48);
  272. extern pascal void SetWinColor(WindowRef theWindow, WCTabHandle newColorTable)
  273.  ONEWORDINLINE(0xAA41);
  274. extern pascal void SetDeskCPat(PixPatHandle deskPixPat)
  275.  ONEWORDINLINE(0xAA47);
  276. extern pascal WindowRef NewCWindow(void *wStorage, const Rect *boundsRect, ConstStr255Param title, Boolean visible, short procID, WindowRef behind, Boolean goAwayFlag, long refCon)
  277.  ONEWORDINLINE(0xAA45);
  278. extern pascal WindowRef GetNewCWindow(short windowID, void *wStorage, WindowRef behind)
  279.  ONEWORDINLINE(0xAA46);
  280. extern pascal short GetWVariant(WindowRef theWindow)
  281.  ONEWORDINLINE(0xA80A);
  282. extern pascal void SetWTitle(WindowRef theWindow, ConstStr255Param title)
  283.  ONEWORDINLINE(0xA91A);
  284. extern pascal Boolean TrackGoAway(WindowRef theWindow, Point thePt)
  285.  ONEWORDINLINE(0xA91E);
  286. extern pascal void DragWindow(WindowRef theWindow, Point startPt, const Rect *boundsRect)
  287.  ONEWORDINLINE(0xA925);
  288. #if CGLUESUPPORTED
  289. extern void setwtitle(WindowRef theWindow, const char *title);
  290. extern Boolean trackgoaway(WindowRef theWindow, Point *thePt);
  291. extern short findwindow(Point *thePoint, WindowRef *theWindow);
  292. extern void getwtitle(WindowRef theWindow, char *title);
  293. extern long growwindow(WindowRef theWindow, Point *startPt, const Rect *bBox);
  294. extern WindowRef newwindow(void *wStorage, const Rect *boundsRect, const char *title, Boolean visible, short theProc, WindowRef behind, Boolean goAwayFlag, long refCon);
  295. extern WindowRef newcwindow(void *wStorage, const Rect *boundsRect, const char *title, Boolean visible, short procID, WindowRef behind, Boolean goAwayFlag, long refCon);
  296. extern long pinrect(const Rect *theRect, Point *thePt);
  297. extern Boolean trackbox(WindowRef theWindow, Point *thePt, short partCode);
  298. extern long draggrayrgn(RgnHandle theRgn, Point *startPt, const Rect *boundsRect, const Rect *slopRect, short axis, DragGrayRgnUPP actionProc);
  299. extern void dragwindow(WindowRef theWindow, Point *startPt, const Rect *boundsRect);
  300. #endif
  301. #if !STRICT_WINDOWS
  302. typedef struct WindowRecord WindowRecord;
  303.  
  304. typedef WindowRecord *WindowPeek;
  305.  
  306. struct WindowRecord {
  307.     GrafPort                        port;
  308.     short                            windowKind;
  309.     Boolean                            visible;
  310.     Boolean                            hilited;
  311.     Boolean                            goAwayFlag;
  312.     Boolean                            spareFlag;
  313.     RgnHandle                        strucRgn;
  314.     RgnHandle                        contRgn;
  315.     RgnHandle                        updateRgn;
  316.     Handle                            windowDefProc;
  317.     Handle                            dataHandle;
  318.     StringHandle                    titleHandle;
  319.     short                            titleWidth;
  320.     ControlRef                        controlList;
  321.     WindowPeek                        nextWindow;
  322.     PicHandle                        windowPic;
  323.     long                            refCon;
  324. };
  325. typedef struct CWindowRecord CWindowRecord;
  326.  
  327. typedef CWindowRecord *CWindowPeek;
  328.  
  329. struct CWindowRecord {
  330.     CGrafPort                        port;
  331.     short                            windowKind;
  332.     Boolean                            visible;
  333.     Boolean                            hilited;
  334.     Boolean                            goAwayFlag;
  335.     Boolean                            spareFlag;
  336.     RgnHandle                        strucRgn;
  337.     RgnHandle                        contRgn;
  338.     RgnHandle                        updateRgn;
  339.     Handle                            windowDefProc;
  340.     Handle                            dataHandle;
  341.     StringHandle                    titleHandle;
  342.     short                            titleWidth;
  343.     ControlRef                        controlList;
  344.     CWindowPeek                        nextWindow;
  345.     PicHandle                        windowPic;
  346.     long                            refCon;
  347. };
  348. struct WStateData {
  349.     Rect                            userState;                    /*user state*/
  350.     Rect                            stdState;                    /*standard state*/
  351. };
  352. typedef struct WStateData WStateData;
  353.  
  354. typedef WStateData *WStateDataPtr, **WStateDataHandle;
  355.  
  356. typedef struct AuxWinRec AuxWinRec;
  357.  
  358. typedef AuxWinRec *AuxWinPtr, **AuxWinHandle;
  359.  
  360. struct AuxWinRec {
  361.     AuxWinHandle                    awNext;                        /*handle to next AuxWinRec*/
  362.     WindowRef                        awOwner;                    /*ptr to window */
  363.     CTabHandle                        awCTable;                    /*color table for this window*/
  364.     UInt32                            reserved;                    /*  */
  365.     long                            awFlags;                    /*reserved for expansion*/
  366.     CTabHandle                        awReserved;                    /*reserved for expansion*/
  367.     long                            awRefCon;                    /*user Constant*/
  368. };
  369. extern pascal Boolean GetAuxWin(WindowRef theWindow, AuxWinHandle *awHndl)
  370.  ONEWORDINLINE(0xAA42);
  371. #endif
  372.  
  373. #ifdef __CFM68K__
  374. #pragma lib_export off
  375. #endif
  376.  
  377. #if GENERATINGPOWERPC
  378. #pragma options align=reset
  379. #endif
  380.  
  381. #ifdef __cplusplus
  382. }
  383. #endif
  384.  
  385. #endif /* __WINDOWS__ */
  386.